package com.android.baseconfig.data.http;

import android.app.Application;
import android.content.Context;

import com.android.baseconfig.data.http.okhttp.OkHttpManager;


public class AppNetDelegate {
    /**
     * Application实例对象
     **/
    private static Application app = null;

    public  static boolean IS_OPEN_PLATFORM= false;  //是否是开放平台

    /**
     * 获取Application的Context
     **/
    public static Context getAppContext() {
        if (app == null) {
            return null;
        }
        return app.getApplicationContext();
    }

    /**
     * 初始化OkHttp
     **/
    public static void initOkHttps(Application application) {
        app = application;
        //设置OkHttp默认信任任何证书
        OkHttpManager.setCertificates();
        //设置OkHttp超时时间，默认15s
        OkHttpManager.setConnectTimeout(15 * 1000);
        OkHttpManager.setReadTimeout(15 * 1000);
        OkHttpManager.setWriteTimeout(15 * 1000);
        // OkHttpManager.setNoProxy();
    }

    public static void initOkHttp(Application application) {
        app = application;
        //设置OkHttp超时时间，默认15s
        OkHttpManager.setConnectTimeout(15 * 1000);
        OkHttpManager.setReadTimeout(15 * 1000);
        OkHttpManager.setWriteTimeout(15 * 1000);
        // OkHttpManager.setNoProxy();
        //网络请求loading框
        // OkHttpManager.addNetworkLoadingListener(new HetProgressDlg());
    }

    public static void setLogger(boolean showLog) {
        OkHttpManager.setLogger(showLog);
    }
}
